<template>
  <div class="content">
    <div class="line">
      <div class="text">
        银行名称：
      </div>
      <div class="input">
        <i-input type="text" v-model="bankName" placeholder="请输入银行名称" style="width: 300px"></i-input>
      </div>
    </div>

    <div class="line">
      <div class="text">
        办卡奖励：
      </div>
      <div class="input">
        <i-input type="text" v-model="bankBonus" placeholder="办卡奖励" style="width: 300px"></i-input>
     </div>
    </div>

    <div class="line">
      <div class="text">
        推荐人返现奖励金额：
      </div>
      <div class="input">
        <i-input type="text" v-model="superiorBonus" placeholder="请输入推荐人返现奖励金额" style="width: 300px"></i-input>
      </div>
    </div>

    <div class="line">
      <div class="text">
        银行图标设置：
      </div>
      <div class="input">
         <UploadImg @showParentComp="showParentComp"></UploadImg>
         <br>
         <img v-if="this.imgUrl" :src="this.imgUrl"  style="width:300px;height:200px">
     </div>
    </div>

    <div class="line">
      <div class="text">
        银行查询进度网址：
      </div>
      <div class="input">
       <i-input type="text" v-model="urlPlanQuery" placeholder="请输入 银行查询进度网址" style="width: 300px"></i-input>
      </div>
    </div>

    <div class="line">
      <div class="text">
        银行办卡快捷网址：
      </div>
      <div class="input">
        <i-input type="text" v-model="urlCreateCard" placeholder="请输入银行办卡快捷网址" style="width: 300px"></i-input>
      </div>
    </div>


    <div class="line">
      <div class="text">
        奖励条件:
      </div>
      <div class="input">
        <select v-model="rewardConditions" style="width:150px">
            <option value="新户核卡" key="1">
              新户核卡
            </option>
            <option value="新户核卡 月核" key="2">
              新户核卡 月核
            </option>
            <option value="新户核卡 周核" key="3">
              新户核卡 周核
            </option>
            <option value="新户初审 月核" key="4">
              新户初审 月核
            </option>
            <option value="不参与奖励" key="5">
              不参与奖励
            </option>
        </select>
     </div>
    </div>

    <div class="line">
      <div class="text">
        是否显示
      </div>
      <div class="input">
        <select v-model="status" style="width:150px">
            <option value="1" key="1">
              是
            </option>
            <option value="0" key="0">
              否
            </option>
        </select>
      </div>
    </div>

     <div class="line">
        <i-button type="info"  @click="handleAddManager">添加银行</i-button>
     </div>


  </div>

</template>

<script>
import axios from 'axios'
import UploadImg from './UploadImg'
export default {
  name: 'BankAdd',

  components: {
    UploadImg
  },
  data () {
    return {
      bankName:'',
      bankBonus:'',
      superiorBonus:'',
      imgUrl:'',
      urlPlanQuery:'',
      urlCreateCard:'',
      rewardConditions:'',
      status:'',
    }
  },
  methods: {
    showParentComp(data){
      this.imgUrl = data
      console.log('imgUrl=============',this.imgUrl)
    },
    handleAddManager(){
      if(this.jianyan()){
        axios.post('/web/api/bank/add',{
          "bankName":this.bankName,
          "bankBonus":this.bankBonus,
          "superiorBonus":this.superiorBonus,
          "img":this.imgUrl,
          "urlPlanQuery":this.urlPlanQuery,
          "urlCreateCard":this.urlCreateCard,
          "rewardConditions":this.rewardConditions,
           "status":this.status,
          }).then(this.handleAddInfoSucc)
      }
    },
    handleAddInfoSucc (res) {
      var data = res.data
      console.log('tag',data)
      this.$Message.success(data.message)
    },
    jianyan(){
      if(this.bankName === ''){
        this.$Message.success("请输入银行名称");
        return false;
      }else if(this.superiorBonus === ''){
        this.$Message.success("请输入推荐人返现奖励金额");
        return false;
      }else if(this.img === ''){
        this.$Message.success("请选择图标");
        return false;
      }else if(this.urlPlanQuery === ''){
        this.$Message.success("请输入银行查询进度链接");
        return false;
      }else if(this.urlCreateCard === ''){
        this.$Message.success("请输入银行办卡链接");
        return false;
      }else if(this.rewardConditions === ''){
        this.$Message.success("请选择奖励条件");
        return false;
      }else{
        return true
      }
    }
  }
}
</script>
<style lang="stylus" scoped>
.content {
    width: 100%;
    text-align: center;
    font-size: 1.8rem;
    line-height: 2.6;
    .line{
      width:80%;
      text-align: center;
      .text{
        text-align :right;
        width:50%;
        float :left;
      }
      .input{
        width:50%;
        float :left;
      }
    }

}
</style>

